import pymysql


class MyDB:
    @staticmethod
    def select_by_id(mobile_no):
        conn = pymysql.connect(host='192.168.1.209', port=3306, user='devenv', passwd='i0tci0', db='gy_p2p_dev',charset='UTF8')
        cur = conn.cursor()
        cur.execute("select content from smslog where mobile = %s and content like '验证码%%'" % mobile_no)
        for i in cur:
            db_val_code = i[0]
        cur.close()
        conn.close()
        db_val_code = db_val_code[4:8]
        print(db_val_code)
        return db_val_code

if __name__ == '__main__':
        print(MyDB.select_by_id('18200001074'))